/**
 * 
 */
package co.fitstart.entity.coach;

import java.math.BigDecimal;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.DynamicUpdate;

import co.fitstart.entity.course.Course;
import co.fitstart.entity.principal.Principal;

import com.demo2do.core.format.DecimalFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

/**
 * @author downpour
 *
 */
@Entity
@Table(name = "coach_settlement")
@DynamicUpdate
@JsonIgnoreProperties(value={"hibernate_lazy_initializer","handler","fieldHandler"})
public class CoachSettlement {

    @Id
    @GeneratedValue
    private Long id;
    
    /** 教练 */
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    private Principal principal;
    
    /** 课程 */
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    private Course course;
    
    /** 结算金额  * 100 */
    @DecimalFormat
    private Integer settlement;
    
    /**
     * The default constructor
     */
    public CoachSettlement() {
        
    }
    
    /**
     * The constructor without settlement
     * 
     * @param principal
     * @param course
     */
    public CoachSettlement(Principal principal, Course course) {
        this.course = course;
        this.principal = principal;
    }
    
    /**
     * The constructor with settlement
     * 
     * @param principal
     * @param course
     * @param settlement
     */
    public CoachSettlement(Principal principal, Course course, BigDecimal settlement) {
        this.principal = principal;
        this.course = course;
        this.settlement = settlement.multiply(new BigDecimal("100")).intValue();
    }

    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @return the principal
     */
    public Principal getPrincipal() {
        return principal;
    }

    /**
     * @return the course
     */
    public Course getCourse() {
        return course;
    }

    /**
     * @return the settlement
     */
    public Integer getSettlement() {
        return settlement;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @param principal the principal to set
     */
    public void setPrincipal(Principal principal) {
        this.principal = principal;
    }

    /**
     * @param course the course to set
     */
    public void setCourse(Course course) {
        this.course = course;
    }

    /**
     * @param settlement the settlement to set
     */
    public void setSettlement(Integer settlement) {
        this.settlement = settlement;
    }
    
}
